//
//  MineSettingViewController.m
//  renmingongshe
//
//  Created by macbook on 2017/10/24.
//  Copyright © 2017年 xiaodian. All rights reserved.
//

#import "MineSettingViewController.h"
#import "LoginViewController.h"
#import "CountSafeViewController.h"

@interface MineSettingViewController ()

@property (weak, nonatomic) IBOutlet UIButton *FirstBtn;
@property (weak, nonatomic) IBOutlet UIButton *PhoneClick;
@property (weak, nonatomic) IBOutlet UIButton *ClearWeb;
@property (weak, nonatomic) IBOutlet UILabel *PhoneLabel;
@end

@implementation MineSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.titleLabel.text = @"设置";
    self.view.backgroundColor = [UIColor colorWithHex:0xf2f2f2];
    
    [_FirstBtn addTarget:self action:@selector(CountSafeCilck) forControlEvents:UIControlEventTouchUpInside];
    [_PhoneClick addTarget:self action:@selector(PhoneCilck) forControlEvents:UIControlEventTouchUpInside];
    [_ClearWeb addTarget:self action:@selector(ClearCilck) forControlEvents:UIControlEventTouchUpInside];
}

- (void)CountSafeCilck
{
    CountSafeViewController *safe = [[CountSafeViewController alloc] init];
    [self.navigationController pushViewController:safe animated:YES];
}

- (void)PhoneCilck
{
    [Utils phone:_PhoneLabel.text controller:self];
}

- (void)ClearCilck
{
    [self.view loadingOnAnyView];
    if (@available(iOS 9.0, *)) {
        NSSet *websiteDataTypes = [WKWebsiteDataStore allWebsiteDataTypes];
        
        //// Date from
        
        NSDate *dateFrom = [NSDate dateWithTimeIntervalSince1970:0];
        
        //// Execute
        
        [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:websiteDataTypes modifiedSince:dateFrom completionHandler:^{
            
            // Done
            [self.view removeAnyView];
            [self.view Message:@"清除成功"];
        }];
    } else {
        // Fallback on earlier versions
    }
}

- (IBAction)LoginOut:(UIButton *)sender {
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"确定退出" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    switch (buttonIndex) {
        case 0:
        {
            break;
        }
        case 1:
        {
            [[NSUserDefaults standardUserDefaults]removeObjectForKey:@"userToken"];
            LoginViewController *login = [[LoginViewController alloc] init];
            [self.navigationController pushViewController:login animated:YES];
        }
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
